package composite_reuse


type GoodProductDAO struct {
	mDBConnection IGoodDBConnection
}

func NewGoodProductDAO() *GoodProductDAO {
	return &GoodProductDAO{}
}

func (me *GoodProductDAO) SetDBConnection(it IGoodDBConnection) {
	me.mDBConnection = it
}

func (me *GoodProductDAO) Insert(it *Product) (error, int) {
	return me.mDBConnection.Execute("insert into product(id,name,price) values(?, ?, ?)", it.ID, it.Name, it.Price)
}

func (me *GoodProductDAO) Update(it *Product) (error, int) {
	return me.mDBConnection.Execute("update product set name=? price=? where id=?", it.Name, it.Price, it.ID)
}

func (me *GoodProductDAO) Delete(id int) (error, int) {
	return me.mDBConnection.Execute("delete from product where id=?", id)
}